package com.example.dirviesystem.student.service;

import com.example.dirviesystem.entity.Question;
import com.example.dirviesystem.repository.StudentQuestionRepository;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.stereotype.Service;

import java.util.List;

@Service
public class StudentQuestionService {

    @Autowired
    private StudentQuestionRepository studentQuestionRepository;

    public List<Question> getAllQuestions() {
        return studentQuestionRepository.findAll();
    }

    public List<Question> getQuestionsBySubject(String subject) {
        return studentQuestionRepository.findBySubject(subject);
    }

    public List<Question> getRandomQuestionsBySubject(String subject, int limit) {
        // 这里调用固定100条随机题的接口，忽略传入的limit参数
        return studentQuestionRepository.findSimulateQuestions(subject);
    }
}